<?php

// use Illuminate\Support\Facades\Schema;
use Jialeo\LaravelSchemaExtend\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class InitSignIn extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('sign_in_records', function (Blueprint $table) {
            $table->comment = '签到表';
            
            $table->increments('id');
            $table->uuid('uuid')->index() ;

            $table->integer('user_id')->unsigned()->index();


            $table->json('days')->nullable()->comment('签到的日期集合');

            $table->string('last_signin', 20)->nullable()->comment('最后签到的日期');
            $table->integer('last_score_reward')->nullable()->comment('最后签到的奖励');
            $table->integer('last_continuous_times')->nullable()->index()->comment('最后一次签到积累的连续签到数');

            $table->softDeletes();
            $table->timestamps();

            $table->foreign('user_id')->references('id')->on('users')
                ->onUpdate('cascade')->onDelete('cascade');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::disableForeignKeyConstraints();
        Schema::dropIfExists('sign_in_records');
    }
}
